def isValid(s):
    if len(s) == 0:
        return True
    stack = []
    for i in s:
        if i in ['(', '[', '{']:
            stack.append(i)
        else:
            if len(stack) == 0:
                return False
            temp = stack.pop()
            if i == ')' and temp != '(':
                return False
            if i == ']' and temp != '[':
                return False
            if i == '}' and temp != '{':
                return False
    return False if stack else True


print(isValid('())'))
print(isValid('()'))
